package main

import "math"

func main() {

}

func maxProfit(prices []int) int {
	minPrice := math.MaxInt
	m := 0
	for i := 0; i < len(prices); i++ {
		if prices[i] < minPrice {
			minPrice = prices[i]
		} else {
			m = max(m, prices[i]-minPrice)
		}
	}
	return m
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
